package com.boost.netty.buf.sbytes;

import com.alibaba.fastjson.JSON;

import java.util.HashMap;
import java.util.Map;

public class Demo {

    public static void main(String[] args) throws Exception {
        Map<String, String> map = new HashMap<>();
        map.put("a", "你好");
        map.put("b", "你好22");
        map.put("c", "你好444");

        StringBuilderPro stringByte = new StringBuilderPro();
        for (Map.Entry<String, String> m : map.entrySet()) {
            stringByte.append(m.getKey(),m.getValue());
            stringByte.append("|");
        }

        stringByte.setWriterIndex(stringByte.getWriterIndex()-"|".getBytes().length);
        stringByte.replace("a","你");
        stringByte.replace("b","7");
        stringByte.replace("c","+999999999999999+");

        //stringByte.append("ssss","fsafds");

        stringByte.insertHead("FDSAFDFDSFDS");
        Filed filed = stringByte.getHeadFiled();
        while (filed!=null){

            Filed filed1 = stringByte.findFiled(filed.getName());
            System.out.println(stringByte.getValue(filed1));
            filed = filed.getNext();
        }

        System.out.println(new String(stringByte.getContent(),0,stringByte.getWriterIndex()));

        StringBuilder s= new StringBuilder();

        System.out.println(JSON.toJSONString(stringByte));
    }
}
